package org.example.test5.configuration;

import org.example.test5.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    // 注册拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 添加拦截器并设置拦截路径
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/card/**")  // 拦截 "/card" 下的所有请求
                .excludePathPatterns("/user/login", "/user/register", "/user/index");  // 排除登录、注册和首页路径
    }
}
